#include <bits/stdc++.h>
using namespace std;
int days[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
bool isLeapYear(int year) {
    return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
}

int main() {
    int y,w;
    cin >> y >> w;
    if (isLeapYear(y)) {
        days[2] = 29;
    }
    bool found = false; // 添加标志变量
    int sum = 0;    
    for (int i = 1; i <= 12; i++) {
        sum += days[i-1];
        int day = ((sum + 13-1) % 7 + w) % 7;
        if (day == 5) {
            cout << i << endl;
            found = true; // 找到黑色星期五
        }
    }
    if (!found) { // 如果没有找到黑色星期五
        cout << "None" << endl;
    }
    return 0;
}
